<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>deme</title>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            height: 200vh;
            overflow-x: hidden;
        }

        .background {
            background-image: url("range.jpg");
            background-size: cover;
            background-position: 50% 50%;
            height: 200vh;
            font: 900 39rem '';
            line-height: 130vh;
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            position: relative;
            text-align: center;
            overflow: hidden;
        }

        .background::before {
            content: '';
            background-size: cover;
            background-image: inherit;
            background-position: 50% 50%;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            z-index: -99;
        }

        h1 {
            position: absolute;
            text-align: center;
            width: 100%;
            letter-spacing: 10px;
            color: #fff;
        }

        h2 {
            position: absolute;
            letter-spacing: 2px;
            top: 120vh;
            width: 60%;
            color: #fff;
            left: 50%;
            transform: translateX(-50%);
            padding: 30px;
            background-color: rgba(0, 0, 0, .3);
        }
    </style>
</head>

<body>
    <h1>测试</h1>
    <div class="background"><span>Goat</span></div>
    <h2>
        In winter, it is covered with snow and snow. When you climb to Jinding, you can see far and wide, and the
        scenery is very magnificent; West overlooking Aiai snow peak, Gongga Mountain and Wawu mountain, the mountains
        connect the sky; Looking south at the top of Ten Thousand Buddhas, the clouds are rolling and the momentum is
        magnificent; A panoramic view of the Pingchuan River in the north is as beautiful as a shop, with a panoramic
        view of the Dadu River and Qingyi River
    </h2>

    <script>
        const background = document.querySelector(".background")

        document.addEventListener('scroll', () => {
            const scrollY = window.scrollY

            if (scrollY !== 0) {
                background.style.backgroundPosition = `calc(50% + ${scrollY}px) calc(50% + ${scrollY}px)`
            }else{
                background.style.backgroundPosition = ''
            }
        })
    </script>
</body>

</html> 